import Vue from 'vue'
import axios from 'axios'
import App from './App.vue'
import VueRouter from 'vue-router'
import routers from "@/routers";
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
axios.interceptors.request.use(
        config => {
            if (sessionStorage.getItem('token')) { //判断token是否存在
                config.headers.Authorization = sessionStorage.getItem('token');  //将token设置成请求头
            }
            return config;
    },
    err => {
        return Promise.reject(err);
    }
);

Vue.use(VueRouter)
const router = new VueRouter({
    mode: 'history',
    routes: routers
})


Vue.prototype.$http = axios

Vue.use(ElementUI)

new Vue({
  el: '#app',
  router,
  render: h => h(App)
})
